import Vue from 'vue';
import iView from 'iview';
import {router} from './router/index';
import {appRouter} from './router/router';
import store from './store';
import App from './app.vue';
import '@/locale';
import 'iview/dist/styles/iview.css';
import VueI18n from 'vue-i18n';
import util from './libs/util';
import Mixin from './mixin';
import axios from "axios";
import qs from 'qs'
axios.defaults.transformRequest= [function (params) {
    if(params===undefined || params.data instanceof FormData===false){
        return qs.stringify(params, { arrayFormat: 'brackets' })
    }else{
        return params.data;
    }
}];
//Import filter
import Filter from './filer'

//引入地图
import VueAMap from 'vue-amap';
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
    key: '0a958544ba678367633c15a1c83539f9',
    plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType'],
    v: '1.4.4'
});
Vue.prototype.$VueAMap = VueAMap;
Vue.prototype.$http = axios;
// Vue.prototype.ajxaHttpUrl = "http://gd16.lnzxjt.cn/hsuadmin/";//xmt.tcy668.com
// Vue.prototype.imgHttpUrl = "http://gd16.lnzxjt.cn";
Vue.prototype.ajxaHttpUrl = process.env.NODE_ENV === 'production'?"http://www.zerolimit.vip/hsuadmin/":"/api/hsuadmin/";//xmt.tcy668.com
Vue.prototype.imgHttpUrl = process.env.NODE_ENV === 'production'?"http://www.zerolimit.vip":"/api";
// Vue.prototype.imgHttpUrl1 = "http://www.bibast.com/"
Vue.prototype.imgHttpUrl1 = "http://www.zerolimit.vip/"
// Vue.prototype.ajxaHttpUrl = process.env.NODE_ENV === 'production'?"http://www.bittorrentbtt.wang/hsuadmin/":"/api/hsuadmin/";//xmt.tcy668.com
// Vue.prototype.imgHttpUrl = process.env.NODE_ENV === 'production'?"http://www.bittorrentbtt.wang":"/api";
Vue.use(VueI18n);
Vue.use(iView);
import mytree from "../src/views/personPage/member/downList/tree"
Vue.component("mytree",mytree)
new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    data: {
        currentPageName: ''
    },
    mounted () {
        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit('setOpenedList');
        this.$store.commit('initCachepage');
        // 权限菜单过滤相关
        this.$store.commit('updateMenulist');
        // iview-admin检查更新
        util.checkUpdate(this);
    },
    created () {
        let tagsList = [];
        appRouter.map((item) => {
            if (item.children.length <= 1) {
                tagsList.push(item.children[0]);
            } else {
                tagsList.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsList);
    }
});
